﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace SyncTool
{
    class Log
    {
        public Log()
        {
            
        }

        public static void info(string text,bool no_date=false) {

            try
            {
                string path = AppDomain.CurrentDomain.BaseDirectory + "\\logs";

                if (!System.IO.Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string fileNameOne = path + "\\" + DateTime.Now.ToString("yyyyMMddHH") + ".log";

                if (!File.Exists(fileNameOne))
                {
                    File.Create(fileNameOne);

                }

                StreamWriter sw = new StreamWriter(fileNameOne, true);

                //FileStream fs = new FileStream(fileNameOne, FileMode.OpenOrCreate);
                //StreamWriter sw = new StreamWriter(fs);

                //开始写入
                if (!no_date)
                {
                    text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":::" + text;
                }
                text += "\r\n";
                sw.Write(text);

                //清空缓冲区
                sw.Flush();
                //关闭流
                sw.Close();
                //fs.Close();
            }
            catch (Exception ee)
            {

            }

        }


    }
}
